from selenium import webdriver
from lxml import etree
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options

# options = Options()
# options.add_argument('--headless')
# br = webdriver.Chrome(options=options)
br = webdriver.Chrome()

br.get(
    "https://aiqicha.baidu.com/s?q=%E4%B8%8A%E6%B5%B7%E5%8C%BB%E8%8D%AF%E9%9B%86%E5%9B%A2%E8%82%A1%E4%BB%BD%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8&t=0")

login = br.find_element_by_xpath('.//span[@class="login"]')
print("登录:>>", login)
login.click()
username = br.find_element(By.XPATH, './/input[@class="pass-text-input pass-text-input-userName"]')
username.send_keys(15136161050)
password = br.find_element(By.XPATH, './/input[@class="pass-text-input pass-text-input-password"]')
password.send_keys("st1282001316")
submit = br.find_element(By.XPATH, './/input[@class="pass-button pass-button-submit"][1]')
submit.click()
# a = br.find_element_by_xpath('/html/body/div[1]/div[1]/div/div[1]/div[2]/div[2]/div/div[1]/div[2]/div/h3/a')
# a.click()
html_str = br.page_source
# print(html_str)
html = etree.HTML(html_str)
link = html.xpath("/html/body/div[1]/div[1]/div/div[1]/div[2]/div[2]/div/div[1]/div[2]/div/h3/a/@href")[0]
print(link)



br.quit()